<?php

function process_booking_json_template($csrf_token) {
	$room_type_ids = get_room_ids();
	$room_type_ids = array_map(function ($room) {
		return $room["id"];
	}, $room_type_ids);
	$room_type_ids = json_encode($room_type_ids);
	$room_type_ids = str_replace('"', '\"', $room_type_ids);
	$to_be_revised = 'const response = await fetch("https://api2.airhost.co/api/one/pms/booking_calendar/bookings/query?locale=zh-CN", {
  "headers": {
		"accept": "application/json",
    "accept-language": "en-US,en;q=0.9",
    "content-type": "application/json",
    "priority": "u=1, i",
    "sec-ch-ua": "\"Google Chrome\";v=\"129\", \"Not=A?Brand\";v=\"8\", \"Chromium\";v=\"129\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-site",
    "x-ah-tenant": "9d6beb13-391a-4729-a949-74eed77bb987",
    "x-csrf-token": "'.$csrf_token.'"
  },
  "referrer": "https://pms.airhost.co/",
  "referrerPolicy": "strict-origin-when-cross-origin",
  "body": "{\"start_date\":\"2024-10-19\",\"end_date\":\"2024-11-18\",\"house_id\":\"\",\"house_tags\":[],\"room_type_ids\":'.$room_type_ids.'}",
  "method": "POST",
  "mode": "cors",
  "credentials": "include"
}); const data = await response.json(); console.log(data);';
	$to_be_revised = str_replace('2024-10-19', date('Y-m-d'), $to_be_revised);
	$to_be_revised = str_replace('2024-11-18', date('Y-m-d', strtotime('+30 days')), $to_be_revised);

	return $to_be_revised;
}